package com.zkingsoft.web.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.matrix.core.exception.GlobleException;
import com.matrix.core.pojo.PaginationVO;
import com.matrix.core.tools.ModelUtils;
import com.zkingsoft.web.bean.WebNav;
import com.zkingsoft.web.dao.WebNavDao;
import com.zkingsoft.web.service.WebNavService;

/**
 * This field was generated by Zking.software.Codegen.
 * @date 2016-11-28 15:35
 */
@Service("webNavService")
public class  WebNavServiceImpl implements    WebNavService  {

	
	@Autowired
	private WebNavDao webNavDao;
	
	
	@Override
	public int add(WebNav webNav){
		
		return webNavDao.insert(webNav);
		
	}
	
	@Override
	public int batchAdd(List<WebNav>  webNavList) {
		return webNavDao.batchInsert(webNavList);
	}
	
	
   	
    @Override
	public int modifyByMap(WebNav oldWebNav
	,WebNav newWebNav){
	
		try {
			if (!ModelUtils.isModified(oldWebNav, newWebNav)) {
				return 1;
			}
		} catch (NoSuchFieldException e1) {
			e1.printStackTrace();
		}
		Map<String, Object> modifyMap=null;
		try {
			modifyMap = ModelUtils.comparePojo2Map(oldWebNav, newWebNav);
		} catch (Exception e) {
			new GlobleException("数据对比失败");
		}
		if (modifyMap.size() > 0) {
			modifyMap.put("navId", oldWebNav.getNavId());
			webNavDao.updateByMap(modifyMap);
		}
		return 1;
	}
	
	@Override
	public int modifyByModel(WebNav webNav){
	
		return webNavDao.updateByModel(webNav);
	
	}
	
	
	
	@Override
	public int remove(List<Long> list){
	
		return webNavDao.deleteByIds(list);
	
	}

	@Override
	public int removeById(Long navId){
	
		return webNavDao.deleteById(navId);
	
	}
	
	@Override
	public int removeByModel(WebNav webNav){
	
		return webNavDao.deleteByModel(webNav);
	
	}
	
	
	@Override
	public List<WebNav> findInPage(WebNav webNav,  PaginationVO pageVo){
	
		return webNavDao.selectInPage(webNav , pageVo);
	
	}
	
	@Override
	public List<WebNav> findByModel(WebNav webNav){
	
		return webNavDao.selectByModel(webNav);
	
	}
	
	@Override
	public int  findTotal(WebNav webNav){
	
		return webNavDao.selectTotalRecord(webNav);
	
	}
	
	@Override
	public WebNav  findById(Long navId){
	
		return webNavDao.selectById(navId);
	
	}

   	
	
	
}